//{width:300, height:500}
function startMove(domobj, obj, fn) {
  clearInterval(domobj.timer);
  domobj.timer = setInterval(() => {
    //假设所有的值都达到了目标值
    let flag = true;
    //取目标值和当前值
    for (let attr in obj) {
      let iTar = obj[attr]; //attr 变量 
      let iCur;
      if (attr == "opacity") {
        iCur = parseInt(getStyle(domobj, attr) * 100);
      } else {
        iCur = parseInt(getStyle(domobj, attr))
      }
      let iSpeed = (iTar - iCur) / 10;
      iSpeed = iSpeed > 0 ? Math.ceil(iSpeed) : Math.floor(iSpeed);
      if (attr == "opacity") {
        domobj.style.opacity = (iCur + iSpeed) / 100;
      } else {
        domobj.style[attr] = iCur + iSpeed + "px";
      }

      /* if (iCur == iTar) { //只要有一个达到目标值 就把定时器清了
        clearInterval(domobj.timer)
      } */
      if (iCur != iTar) {
        flag = false; //只要有一个没有达到目标值，假设不成立
      }
    }

    if (flag) {
      clearInterval(domobj.timer)
      if (fn) {
        fn();
      }

    }



  }, 20);
}

function getStyle(domobj, attr) {
  if (window.getComputedStyle) {
    return window.getComputedStyle(domobj, null)[attr];
  }
  return domobj.currentStyle[attr];
}